<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<html><head><title>QDockWidget Class Reference</title><style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm }
a:link { color: #004faf; text-decoration: none }
a:visited { color: #672967; text-decoration: none }
td.postheader { font-family: sans-serif }
tr.address { font-family: sans-serif }
body { background: #ffffff; color: black; }
</style></head><body><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr /><td align="left" valign="top" width="32"><img align="left" border="0" height="32" src="images/rb-logo.png" width="32" /></td><td width="1">&#160;&#160;</td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a>&#160;&#183; <a href="classes.html"><font color="#004faf">All Classes</font></a>&#160;&#183; <a href="modules.html"><font color="#004faf">Modules</font></a></td></table><h1 align="center">QDockWidget Class Reference<br /><sup><sup>[<a href="qtgui.html">QtGui</a> module]</sup></sup></h1><p>The QDockWidget class provides a widget that can be docked
inside a <a href="qmainwindow.html">QMainWindow</a> or floated as a
top-level window on the desktop. <a href="#details">More...</a></p>

<p>Inherits <a href="qwidget.html">QWidget</a>.</p><h3>Types</h3><ul><li><div class="fn" />enum <b><a href="qdockwidget.html#DockWidgetFeature-enum">DockWidgetFeature</a></b> { DockWidgetClosable, DockWidgetMovable, DockWidgetFloatable, DockWidgetVerticalTitleBar, AllDockWidgetFeatures, NoDockWidgetFeatures }</li><li><div class="fn" />class <b><a href="qdockwidget-dockwidgetfeatures.html">DockWidgetFeatures</a></b></li></ul><h3>Methods</h3><ul><li><div class="fn" /><b><a href="qdockwidget.html#QDockWidget">__init__</a></b> (<i>self</i>, QString&#160;<i>title</i>, QWidget&#160;<i>parent</i>&#160;=&#160;None, Qt.WindowFlags&#160;<i>flags</i>&#160;=&#160;0)</li><li><div class="fn" /><b><a href="qdockwidget.html#QDockWidget-2">__init__</a></b> (<i>self</i>, QWidget&#160;<i>parent</i>&#160;=&#160;None, Qt.WindowFlags&#160;<i>flags</i>&#160;=&#160;0)</li><li><div class="fn" />Qt.DockWidgetAreas <b><a href="qdockwidget.html#allowedAreas">allowedAreas</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qdockwidget.html#changeEvent">changeEvent</a></b> (<i>self</i>, QEvent&#160;<i>event</i>)</li><li><div class="fn" /><b><a href="qdockwidget.html#closeEvent">closeEvent</a></b> (<i>self</i>, QCloseEvent&#160;<i>event</i>)</li><li><div class="fn" />bool <b><a href="qdockwidget.html#event">event</a></b> (<i>self</i>, QEvent&#160;<i>event</i>)</li><li><div class="fn" />DockWidgetFeatures <b><a href="qdockwidget.html#features">features</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qdockwidget.html#initStyleOption">initStyleOption</a></b> (<i>self</i>, QStyleOptionDockWidget&#160;<i>option</i>)</li><li><div class="fn" />bool <b><a href="qdockwidget.html#isAreaAllowed">isAreaAllowed</a></b> (<i>self</i>, Qt.DockWidgetArea&#160;<i>area</i>)</li><li><div class="fn" />bool <b><a href="qdockwidget.html#isFloating">isFloating</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qdockwidget.html#paintEvent">paintEvent</a></b> (<i>self</i>, QPaintEvent&#160;<i>event</i>)</li><li><div class="fn" /><b><a href="qdockwidget.html#setAllowedAreas">setAllowedAreas</a></b> (<i>self</i>, Qt.DockWidgetAreas&#160;<i>areas</i>)</li><li><div class="fn" /><b><a href="qdockwidget.html#setFeatures">setFeatures</a></b> (<i>self</i>, DockWidgetFeatures&#160;<i>features</i>)</li><li><div class="fn" /><b><a href="qdockwidget.html#setFloating">setFloating</a></b> (<i>self</i>, bool&#160;<i>floating</i>)</li><li><div class="fn" /><b><a href="qdockwidget.html#setTitleBarWidget">setTitleBarWidget</a></b> (<i>self</i>, QWidget&#160;<i>widget</i>)</li><li><div class="fn" /><b><a href="qdockwidget.html#setWidget">setWidget</a></b> (<i>self</i>, QWidget&#160;<i>widget</i>)</li><li><div class="fn" />QWidget <b><a href="qdockwidget.html#titleBarWidget">titleBarWidget</a></b> (<i>self</i>)</li><li><div class="fn" />QAction <b><a href="qdockwidget.html#toggleViewAction">toggleViewAction</a></b> (<i>self</i>)</li><li><div class="fn" />QWidget <b><a href="qdockwidget.html#widget">widget</a></b> (<i>self</i>)</li></ul><h3>Qt Signals</h3><ul><li><div class="fn" />void <b><a href="qdockwidget.html#allowedAreasChanged">allowedAreasChanged</a></b> (Qt::DockWidgetAreas)</li><li><div class="fn" />void <b><a href="qdockwidget.html#dockLocationChanged">dockLocationChanged</a></b> (Qt::DockWidgetArea)</li><li><div class="fn" />void <b><a href="qdockwidget.html#featuresChanged">featuresChanged</a></b> (QDockWidget::DockWidgetFeatures)</li><li><div class="fn" />void <b><a href="qdockwidget.html#topLevelChanged">topLevelChanged</a></b> (bool)</li><li><div class="fn" />void <b><a href="qdockwidget.html#visibilityChanged">visibilityChanged</a></b> (bool)</li></ul><a name="details" /><hr /><h2>Detailed Description</h2><p>The QDockWidget class provides a widget that can be docked
inside a <a href="qmainwindow.html">QMainWindow</a> or floated as a
top-level window on the desktop.</p>
<p>QDockWidget provides the concept of dock widgets, also know as
tool palettes or utility windows. Dock windows are secondary
windows placed in the <i>dock widget area</i> around the <a href="qmainwindow.html#centralWidget">central widget</a> in a <a href="qmainwindow.html">QMainWindow</a>.</p>
<p class="centerAlign"><img src="images/mainwindow-docks.png" /></p>
<p>Dock windows can be moved inside their current area, moved into
new areas and floated (e.g., undocked) by the end-user. The
QDockWidget API allows the programmer to restrict the dock widgets
ability to move, float and close, as well as the areas in which
they can be placed.</p>
<a id="appearance" name="appearance" />
<h3>Appearance</h3>
<p>A QDockWidget consists of a title bar and the content area. The
title bar displays the dock widgets <a href="qwidget.html#windowTitle-prop">window title</a>, a <i>float</i>
button and a <i>close</i> button. Depending on the state of the
QDockWidget, the <i>float</i> and <i>close</i> buttons may be
either disabled or not shown at all.</p>
<p>The visual appearance of the title bar and buttons is dependent
on the <a href="qstyle.html">style</a> in use.</p>
<p>A QDockWidget acts as a wrapper for its child widget, set with
<a href="qdockwidget.html#setWidget">setWidget</a>(). Custom size
hints, minimum and maximum sizes and size policies should be
implemented in the child widget. QDockWidget will respect them,
adjusting its own constraints to include the frame and title. Size
constraints should not be set on the QDockWidget itself, because
they change depending on whether it is docked; a docked QDockWidget
has no frame and a smaller title bar.</p>
<hr /><h2>Type Documentation</h2><h3 class="fn"><a name="DockWidgetFeature-enum" />QDockWidget.DockWidgetFeature</h3><table class="valuelist">
<tr class="odd" valign="top">
<th class="tblConst">Constant</th>
<th class="tblval">Value</th>
<th class="tbldscr">Description</th>
</tr>
<tr>
<td class="topAlign"><tt>QDockWidget.DockWidgetClosable</tt></td>
<td class="topAlign"><tt>0x01</tt></td>
<td class="topAlign">The dock widget can be closed. On some systems
the dock widget always has a close button when it's floating (for
example on MacOS 10.5).</td>
</tr>
<tr>
<td class="topAlign"><tt>QDockWidget.DockWidgetMovable</tt></td>
<td class="topAlign"><tt>0x02</tt></td>
<td class="topAlign">The dock widget can be moved between docks by
the user.</td>
</tr>
<tr>
<td class="topAlign"><tt>QDockWidget.DockWidgetFloatable</tt></td>
<td class="topAlign"><tt>0x04</tt></td>
<td class="topAlign">The dock widget can be detached from the main
window, and floated as an independent window.</td>
</tr>
<tr>
<td class="topAlign">
<tt>QDockWidget.DockWidgetVerticalTitleBar</tt></td>
<td class="topAlign"><tt>0x08</tt></td>
<td class="topAlign">The dock widget displays a vertical title bar
on its left side. This can be used to increase the amount of
vertical space in a <a href="qmainwindow.html">QMainWindow</a>.</td>
</tr>
<tr>
<td class="topAlign">
<tt>QDockWidget.AllDockWidgetFeatures</tt></td>
<td class="topAlign"><tt>DockWidgetClosable | DockWidgetMovable |
DockWidgetFloatable</tt></td>
<td class="topAlign">(Deprecated) The dock widget can be closed,
moved, and floated. Since new features might be added in future
releases, the look and behavior of dock widgets might change if you
use this flag. Please specify individual flags instead.</td>
</tr>
<tr>
<td class="topAlign">
<tt>QDockWidget.NoDockWidgetFeatures</tt></td>
<td class="topAlign"><tt>0x00</tt></td>
<td class="topAlign">The dock widget cannot be closed, moved, or
floated.</td>
</tr>
</table>
<p>The DockWidgetFeatures type is a typedef for <a href="qflags.html">QFlags</a>&lt;DockWidgetFeature&gt;. It stores an OR
combination of DockWidgetFeature values.</p>
<hr /><h2>Method Documentation</h2><h3 class="fn"><a name="QDockWidget" />QDockWidget.__init__ (<i>self</i>, QString&#160;<i>title</i>, <a href="qwidget.html">QWidget</a>&#160;<i>parent</i>&#160;=&#160;None, <a href="qt-windowflags.html">Qt.WindowFlags</a>&#160;<i>flags</i>&#160;=&#160;0)</h3><p>The <i>parent</i> argument, if not None, causes <i>self</i> to be owned by Qt instead of PyQt.</p><p>Constructs a <a href="qdockwidget.html">QDockWidget</a> with
parent <i>parent</i> and window flags <i>flags</i>. The dock widget
will be placed in the left dock widget area.</p>
<p>The window title is set to <i>title</i>. This title is used when
the <a href="qdockwidget.html">QDockWidget</a> is docked and
undocked. It is also used in the context menu provided by <a href="qmainwindow.html">QMainWindow</a>.</p>
<p><b>See also</b> <a href="qwidget.html#windowTitle-prop">setWindowTitle</a>().</p>


<h3 class="fn"><a name="QDockWidget-2" />QDockWidget.__init__ (<i>self</i>, <a href="qwidget.html">QWidget</a>&#160;<i>parent</i>&#160;=&#160;None, <a href="qt-windowflags.html">Qt.WindowFlags</a>&#160;<i>flags</i>&#160;=&#160;0)</h3><p>The <i>parent</i> argument, if not None, causes <i>self</i> to be owned by Qt instead of PyQt.</p><p>Constructs a <a href="qdockwidget.html">QDockWidget</a> with
parent <i>parent</i> and window flags <i>flags</i>. The dock widget
will be placed in the left dock widget area.</p>


<h3 class="fn"><a name="allowedAreas" /><a href="qt-dockwidgetareas.html">Qt.DockWidgetAreas</a> QDockWidget.allowedAreas (<i>self</i>)</h3><h3 class="fn"><a name="changeEvent" />QDockWidget.changeEvent (<i>self</i>, <a href="qevent.html">QEvent</a>&#160;<i>event</i>)</h3><p>Reimplemented from <a href="qwidget.html#changeEvent">QWidget.changeEvent</a>().</p>


<h3 class="fn"><a name="closeEvent" />QDockWidget.closeEvent (<i>self</i>, <a href="qcloseevent.html">QCloseEvent</a>&#160;<i>event</i>)</h3><p>Reimplemented from <a href="qwidget.html#closeEvent">QWidget.closeEvent</a>().</p>


<h3 class="fn"><a name="event" />bool QDockWidget.event (<i>self</i>, <a href="qevent.html">QEvent</a>&#160;<i>event</i>)</h3><p>Reimplemented from <a href="qobject.html#event">QObject.event</a>().</p>


<h3 class="fn"><a name="features" /><a href="qdockwidget-dockwidgetfeatures.html">DockWidgetFeatures</a> QDockWidget.features (<i>self</i>)</h3><h3 class="fn"><a name="initStyleOption" />QDockWidget.initStyleOption (<i>self</i>, <a href="qstyleoptiondockwidget.html">QStyleOptionDockWidget</a>&#160;<i>option</i>)</h3><p>Initialize <i>option</i> with the values from this <a href="qdockwidget.html">QDockWidget</a>. This method is useful for
subclasses when they need a <a href="qstyleoptiondockwidget.html">QStyleOptionDockWidget</a>, but don't
want to fill in all the information themselves.</p>
<p><b>See also</b> <a href="qstyleoption.html#initFrom">QStyleOption.initFrom</a>().</p>


<h3 class="fn"><a name="isAreaAllowed" />bool QDockWidget.isAreaAllowed (<i>self</i>, <a href="qt.html#DockWidgetArea-enum">Qt.DockWidgetArea</a>&#160;<i>area</i>)</h3><p>Returns true if this dock widget can be placed in the given
<i>area</i>; otherwise returns false.</p>


<h3 class="fn"><a name="isFloating" />bool QDockWidget.isFloating (<i>self</i>)</h3><h3 class="fn"><a name="paintEvent" />QDockWidget.paintEvent (<i>self</i>, <a href="qpaintevent.html">QPaintEvent</a>&#160;<i>event</i>)</h3><p>Reimplemented from <a href="qwidget.html#paintEvent">QWidget.paintEvent</a>().</p>


<h3 class="fn"><a name="setAllowedAreas" />QDockWidget.setAllowedAreas (<i>self</i>, <a href="qt-dockwidgetareas.html">Qt.DockWidgetAreas</a>&#160;<i>areas</i>)</h3><h3 class="fn"><a name="setFeatures" />QDockWidget.setFeatures (<i>self</i>, <a href="qdockwidget-dockwidgetfeatures.html">DockWidgetFeatures</a>&#160;<i>features</i>)</h3><h3 class="fn"><a name="setFloating" />QDockWidget.setFloating (<i>self</i>, bool&#160;<i>floating</i>)</h3><h3 class="fn"><a name="setTitleBarWidget" />QDockWidget.setTitleBarWidget (<i>self</i>, <a href="qwidget.html">QWidget</a>&#160;<i>widget</i>)</h3><p>The <i>widget</i> argument has it's ownership transferred to Qt.</p><p>Sets an arbitrary <i>widget</i> as the dock widget's title bar.
If <i>widget</i> is 0, any custom title bar widget previously set
on the dock widget is removed, but not deleted, and the default
title bar will be used instead.</p>
<p>If a title bar widget is set, <a href="qdockwidget.html">QDockWidget</a> will not use native window
decorations when it is floated.</p>
<p>Here are some tips for implementing custom title bars:</p>
<ul>
<li>Mouse events that are not explicitly handled by the title bar
widget must be ignored by calling <a href="qevent.html#ignore">QMouseEvent.ignore</a>(). These events then
propagate to the <a href="qdockwidget.html">QDockWidget</a> parent,
which handles them in the usual manner, moving when the title bar
is dragged, docking and undocking when it is double-clicked,
etc.</li>
<li>When <a href="qdockwidget.html#DockWidgetFeature-enum">DockWidgetVerticalTitleBar</a>
is set on <a href="qdockwidget.html">QDockWidget</a>, the title bar
widget is repositioned accordingly. In <a href="qwidget.html#resizeEvent">resizeEvent</a>(), the title bar should
check what orientation it should assume:
<pre class="cpp">
 <span class="type"><a href="qdockwidget.html">QDockWidget</a></span> <span class="operator">*</span>dockWidget <span class="operator">=</span> qobject_cast<span class="operator">&lt;</span><span class="type"><a href="qdockwidget.html">QDockWidget</a></span><span class="operator">*</span><span class="operator">&gt;</span>(parentWidget());
 <span class="keyword">if</span> (dockWidget<span class="operator">-</span><span class="operator">&gt;</span>features() <span class="operator">&amp;</span> <span class="type"><a href="qdockwidget.html">QDockWidget</a></span><span class="operator">.</span>DockWidgetVerticalTitleBar) {
     <span class="comment">// I need to be vertical</span>
 } <span class="keyword">else</span> {
     <span class="comment">// I need to be horizontal</span>
 }
</pre></li>
<li>The title bar widget must have a valid <a href="qwidget.html#sizeHint-prop">QWidget.sizeHint</a>() and <a href="qwidget.html#minimumSizeHint-prop">QWidget.minimumSizeHint</a>().
These functions should take into account the current orientation of
the title bar.</li>
<li>It is not possible to remove a title bar from a dock widget.
However, a similar effect can be achieved by setting a default
constructed <a href="qwidget.html">QWidget</a> as the title bar
widget.</li>
</ul>
<p>Using <a href="qobject.html#qobject_cast">qobject_cast</a>() as
shown above, the title bar widget has full access to its parent
<a href="qdockwidget.html">QDockWidget</a>. Hence it can perform
such operations as docking and hiding in response to user
actions.</p>
<p>This function was introduced in Qt 4.3.</p>
<p><b>See also</b> <a href="qdockwidget.html#titleBarWidget">titleBarWidget</a>() and <a href="qdockwidget.html#DockWidgetFeature-enum">DockWidgetVerticalTitleBar</a>.</p>


<h3 class="fn"><a name="setWidget" />QDockWidget.setWidget (<i>self</i>, <a href="qwidget.html">QWidget</a>&#160;<i>widget</i>)</h3><p>The <i>widget</i> argument has it's ownership transferred to Qt.</p><p>Sets the widget for the dock widget to <i>widget</i>.</p>
<p>If the dock widget is visible when <i>widget</i> is added, you
must <a href="qwidget.html#show">show()</a> it explicitly.</p>
<p>Note that you must add the layout of the <i>widget</i> before
you call this function; if not, the <i>widget</i> will not be
visible.</p>
<p><b>See also</b> <a href="qdockwidget.html#widget">widget</a>().</p>


<h3 class="fn"><a name="titleBarWidget" /><a href="qwidget.html">QWidget</a> QDockWidget.titleBarWidget (<i>self</i>)</h3><p>Returns the custom title bar widget set on the <a href="qdockwidget.html">QDockWidget</a>, or 0 if no custom title bar has
been set.</p>
<p>This function was introduced in Qt 4.3.</p>
<p><b>See also</b> <a href="qdockwidget.html#setTitleBarWidget">setTitleBarWidget</a>().</p>


<h3 class="fn"><a name="toggleViewAction" /><a href="qaction.html">QAction</a> QDockWidget.toggleViewAction (<i>self</i>)</h3><p>Returns a checkable action that can be used to show or close
this dock widget.</p>
<p>The action's text is set to the dock widget's window title.</p>
<p><b>See also</b> <a href="qaction.html#text-prop">QAction.text</a> and <a href="qwidget.html#windowTitle-prop">QWidget.windowTitle</a>.</p>


<h3 class="fn"><a name="widget" /><a href="qwidget.html">QWidget</a> QDockWidget.widget (<i>self</i>)</h3><p>Returns the widget for the dock widget. This function returns
zero if the widget has not been set.</p>
<p><b>See also</b> <a href="qdockwidget.html#setWidget">setWidget</a>().</p>
<hr /><h2>Qt Signal Documentation</h2><h3 class="fn"><a name="allowedAreasChanged" />void allowedAreasChanged (Qt::DockWidgetAreas)</h3><p>This is the default overload of this signal.</p><p>This signal is emitted when the <a href="qdockwidget.html#allowedAreas-prop">allowedAreas</a> property
changes. The <i>allowedAreas</i> parameter gives the new value of
the property.</p>


<h3 class="fn"><a name="dockLocationChanged" />void dockLocationChanged (Qt::DockWidgetArea)</h3><p>This is the default overload of this signal.</p><p>This signal is emitted when the dock widget is moved to another
dock <i>area</i>, or is moved to a different location in its
current dock area. This happens when the dock widget is moved
programmatically or is dragged to a new location by the user.</p>
<p>This function was introduced in Qt 4.3.</p>


<h3 class="fn"><a name="featuresChanged" />void featuresChanged (QDockWidget::DockWidgetFeatures)</h3><p>This is the default overload of this signal.</p><p>This signal is emitted when the <a href="qdockwidget.html#features-prop">features</a> property changes. The
<i>features</i> parameter gives the new value of the property.</p>


<h3 class="fn"><a name="topLevelChanged" />void topLevelChanged (bool)</h3><p>This is the default overload of this signal.</p><p>This signal is emitted when the <a href="qdockwidget.html#floating-prop">floating</a> property changes. The
<i>topLevel</i> parameter is true if the dock widget is now
floating; otherwise it is false.</p>
<p><b>See also</b> <a href="qwidget.html#isWindow">isWindow</a>().</p>


<h3 class="fn"><a name="visibilityChanged" />void visibilityChanged (bool)</h3><p>This is the default overload of this signal.</p><p>This signal is emitted when the dock widget becomes
<i>visible</i> (or invisible). This happens when the widget is
hidden or shown, as well as when it is docked in a tabbed dock area
and its tab becomes selected or unselected.</p>
<p>This function was introduced in Qt 4.3.</p>


<address><hr /><div align="center"><table border="0" cellspacing="0" width="100%"><tr class="address"><td align="left" width="25%">PyQt&#160;4.9.1 for X11</td><td align="center" width="50%">Copyright &#169; <a href="http://www.riverbankcomputing.com">Riverbank&#160;Computing&#160;Ltd</a> and <a href="http://www.qtsoftware.com">Nokia</a> 2011</td><td align="right" width="25%">Qt&#160;4.8.0</td></tr></table></div></address></body></html>